package com.eco.utils;

import com.eco.constants.Constants;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author: xulinyu
 * @date: 2024/6/24 20:04  康奈德继电器方法
 */

@Slf4j
@Component
public class KndUtil {

    public static void sendCommand(String clientId, String command) {
        try{
            String msg = new String(command.getBytes(), "utf-8");
            ChannelHandlerContext ctx = NettyCtxMap.get(clientId);
            ctx.writeAndFlush(msg);
            log.info("向继电器[{}]发送指令[{}]成功", clientId, msg);
        }catch (Exception e){
            log.error(e.getMessage(),e);
        }

    }


}
